package com.dronff.promise4j;


import java.util.LinkedList;
import java.util.Queue;

public class Promise {
    Queue<PromiseFunction> functionQueue = new LinkedList<>();
    public Promise(PromiseFunction function){
        functionQueue.add(function);
    }
    public Promise then(PromiseFunction function){
        functionQueue.add(function);
        return  this;
    }
    public Promise send(Object...args){
        PromiseFunction function = functionQueue.poll();
        function.run(this);
        return this;
    }
}
